cmake_minimum_required(VERSION 3.19)
project(QMapper LANGUAGES CXX)

# set(CMAKE_AUTOUIC ON)
# set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_definitions(-D QT)
include(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/CMakeLists.txt)

find_package(Qt6 6.5 REQUIRED COMPONENTS Core Widgets)

qt_standard_project_setup()

qt_add_executable(QMapper
    WIN32 MACOSX_BUNDLE
    ${THIRDPARTY}
    assets.qrc

    main.cpp
    MainWindow.cpp
    MainWindow.hpp
    MainWindow.ui

    classes/base/csv/Csv.hpp classes/base/csv/Csv.cpp
    classes/base/date/Date.hpp classes/base/date/Date.cpp
    classes/base/json/Json.hpp classes/base/json/Json.cpp
    classes/base/random/Random.hpp classes/base/random/Random.cpp

    classes/about/AboutDialog.hpp classes/about/AboutDialog.cpp classes/about/AboutDialog.ui
    classes/licence/LicenceRegistDialog.hpp classes/licence/LicenceRegistDialog.cpp classes/licence/LicenceRegistDialog.ui
    classes/licence/Licence.hpp classes/licence/Licence.cpp
    classes/licence/LicenceManagerDialog.hpp classes/licence/LicenceManagerDialog.cpp classes/licence/LicenceManagerDialog.ui
    classes/licence/LicenceManager.hpp classes/licence/LicenceManager.cpp
    classes/base/json/JsonParser.inl
    classes/base/json/JsonParserStd.inl
    classes/base/json/JsonParserQt.inl
    classes/base/json/JsonParser.hpp classes/base/json/JsonParser.cpp
)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
# set_target_properties(appQMMapper PROPERTIES
# #    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.appQMMapper
#     MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
#     MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
#     MACOSX_BUNDLE TRUE
#     WIN32_EXECUTABLE TRUE
# )

target_link_libraries(QMapper
    PRIVATE
        Qt::Core
        Qt::Widgets
)

include(GNUInstallDirs)

install(TARGETS QMapper
    BUNDLE  DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

qt_generate_deploy_app_script(
    TARGET QMapper
    OUTPUT_SCRIPT deploy_script
    NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
